import http from '../http'

const api = '/manage/'

export function country() {
  return http.get(api + 'country')
}

export function permission(id) {
  return http.get(api + 'permission', {
    params: { 
      id
    }
  })
}

export function plugin(id) {
  return http.get(api + 'plugin', {
    params: { 
      id,
      permission: process.env.VUE_APP_PERMISSION
    }
  })
}

export function template(params) {
  return http.get(api + 'template', {
    params
  })
}

export function checkout(token) {
  return http.get(api + 'checkout', {
    params: { token }
  })
}

export function news(params) {
  return http.get(api + 'news', {
    params
  })
}

export function version(params) {
  return http.get(api + 'version', {
    params
  })
}

export function upload(type, file) {
  // 组合对象
  const data = new FormData()
  data.append('type', type)
  data.append('file', file)

  return http.post(api + 'upload', data)
}